package com.sky.mapper;

import com.sky.entity.NewUsers;
import com.sky.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

/**
 * @Classname UserEmployeeMapper
 * @Description TODO
 * @Version 1.0.0
 * @Date 2024/7/3 12:00
 * @Created by Ren
 */
@Mapper
public interface UserEmployeeMapper {

    /**
     * 插入user数据
     *
     * @param user
     * @return
     */
    Integer insertUser(User user);

    /**
     * 根据 openid返回user数据
     *
     * @param openid
     * @return
     */
    @Select("select * from user where openid = #{openid}")
    User selectByOpenId(String openid);

    /**
     * 根据 id返回User对象
     * @param id
     * @return
     */
    User getById(Long id);

    List<NewUsers> getUserStatistics(LocalDateTime beginDateTime, LocalDateTime endDateTime);

    @Select("    SELECT COUNT(*) AS total_users FROM user WHERE create_time < #{localDateTime}")
    Long getUserCountLocal(LocalDateTime localDateTime);

    Integer countByMap(Map map);

}
